home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
pascal
/
grafxtp.exe
/
GRAPHICS.DOC
< prev
next >
Wrap
Text File
|
1991-04-25
|
9KB
|
185 lines
Unit Graphics;
{ Turbo Pascal 6.0 unit for graphics handling. Provides a generic graphic
container object and procedures to manipulate the object. All of the pro-
cedures are written to deal with a rectangular area of the screen which
will be, or will contain, a graphic image. Currently, the actual image
generation is up to the programmer - Drawing tools may be included at a
later date. Of course, you MUST be in graphics mode before instantiating
an object of type Graphic.
Written By Jim Fralix. I can be reached on CompuServe (ID# 72317,3614) or
in writing at : Jim Fralix
415 Parkdale Dr. #5B
Charleston, SC 29414.
This version is public domain, or FreeWare, with the anticipation of future
releases with more features that will eventually be marketed as Shareware.
Please feel free to copy, distribute, and use this unit. I only ask that
you do not modify the documentation or code when distributing these files to
others. I will accept no liability for the use or misuse of this material.
If your keyboard breaks in half, you own both halves!
The commented Interface portion of the code (shown below) will serve as the
documentation and reference material. The source code for this unit will
NOT be published unless this evolves into shareware. Registered users of a
future shareware version WILL be provided with the source code. I made all
of the object procedures Virtual so that they may be extended for any descen-
dant type objects.
This is version 1.00 as it is the first version I have distributed for public
use. This unit was written for a specific project and does everything I
needed it to do, so upgrades and bug fixes will depend largely on user feed-
back. I am distributing this version free, hoping that I can get a lot of
input from the users. Responses (or lack thereof) will determine the future
of this unit, so please let me know what you think!
}
Interface
Uses Graph;
Const
{ Directions }
Up : Byte = 1; Right : Byte = 2; Down : Byte = 3; Left : Byte = 4;
{ Put Types }
CopyPut = 0; XOrPut = 1; OrPut = 2; AndPut = 3; NotPut = 4;
Type
Coordinates = Record { Used in Graphic Object }
X,
Y : Integer;
End;
Graphic = Object { This is the object type you will be using! }
OK : Boolean; { Set by procs marked with (**) }
(**) Constructor Init (x1,y1,x2,y2 : Word);
{ Allocates memory for screen image rectangle bounded by x1,y1
at the top left corner and x2,y2 at the bottom right corner.
Sets OK to false if unable to allocate the memory needed.
Max image size in 640 x 350 x 16 color mode is a little more
than half a screen. The amount of the screen you can "grab"
will vary according to the graphics mode, but the image must
require <= 64K. Can be called by the New method. }
(**) Procedure Relocate (X, Y : Integer);
{ Makes X,Y the new top left corner of the graphic. This pro-
cedure does not display the image at the new position, but
sets other object parameters as required. If the new position
would "push" any of the image off the screen, the position is
adjusted to be as close as possible to the position requested
while keeping the entire image on screen. }
Procedure Get;
{ Takes a "snapshot" of the image bounded by currently defined
rectangle }
(**) Procedure Put (PutType : Word);
{ Places the image on screen in the currently defined position.
PutType determines how the image is shown. The following
descriptions are meant to give you a feel for what effect the
different types of puts will have, but some experimenting of
your own is in order as these are very general descriptions.
CopyPut makes an exact copy of the image, but any existing
image "under" the new image is obliterated. XOrPut will pre-
serve the underlying image, and will restore to original if
called twice in a row. OrPut will put an "opaque" image that
will allow both images to be seen (some color distortions may
occur where the images overlap). NotPut does a reverse image
CopyPut. }
(**) Procedure CopyTo (X, Y : Integer; PutType : Byte);
{ Copies image to X,Y and puts image with PutType. Makes X,Y
the new top left corner of rectangle }
(**) Procedure MoveTo (X, Y : Integer; PutType : Byte);
{ Does an XOrPut of image, relocates to X,Y, and puts image with
PutType. Makes X,Y the new top left corner of rectangle }
(**) Procedure DragIt (Direction, Amount : Byte);
{ Temporarily puts image on screen offset "amount" positions in
"Direction" from current rectangle or last DragIt position.
Once a drag has been started, the drag must be ended with the
EndDrag procedure below. Each call to DragIt updates the
graphic rectangle location - to restore back to location before
the DragIt call(s) were made, call AbortDrag procedure. }
Procedure EndDrag;
{ Use to end DragIt - erases last image put on screen }
Procedure AbortDrag;
{ Use to abort drag and restore original rectangle. }
Procedure Write (Var SaveFile : File);
{ Writes graphic image to a file. The file should be untyped and
opened with a record size of 1 (see the rewrite procedure docs
for more details). Writes the size, screen location coordi-
nates, and image info to the file. Each write takes 10 bytes
plus the size of the image. Multiple images may be written to
the same file, but must be read sequentially. }
Procedure Read (Var ReadFile : File);
{ Reads a graphic image from a file. The file should be untyped
and opened with a record size of 1. Reads the size, screen
location coordinates, and image info. If necessary, re-allo-
cates memory for the image. }
Destructor Done;
{ Call when finished using an image. De-allocates memory for the
image, can be called by dispose method. }
Private
----------------end-of-author's-documentation---------------
Software Library Information:
This disk copy provided as a service of
Public (software) Library
We are not the authors of this program, nor are we associated
with the author in any way other than as a distributor of the
program in accordance with the author's terms of distribution.
Please direct shareware payments and specific questions about
this program to the author of the program, whose name appears
elsewhere in this documentation. If you have trouble getting
in touch with the author, we will do whatever we can to help
you with your questions. All programs have been tested and do
run. To report problems, please use the form that is in the
file PROBLEM.DOC on many of our disks or in other written for-
mat with screen printouts, if possible. PsL cannot debug pro-
programs over the telephone, though we can answer questions.
Disks in the PsL are updated monthly, so if you did not get
this disk directly from the PsL, you should be aware that the
files in this set may no longer be the current versions. Also,
if you got this disk from another vendor and are having prob-
lems, be aware that some fi